package com.hy.utils;

import java.sql.*;

public class DBManager {
	public static final String URL = "jdbc:mysql://127.0.0.1/zhihu?characterEncoding=utf8";
	public static final String USER = "root";
	public static final String PWD = "root";
	
	public static Connection getConn() throws Exception{
		Class.forName("com.mysql.jdbc.Driver");
		Connection conn = DriverManager.getConnection(URL, USER, PWD);
		return conn;
	}
	
	public static void close(Connection conn,PreparedStatement ps,ResultSet rs) throws SQLException{
		if(rs != null) {
			rs.close();
		}
		if(ps != null) {
			ps.close();
		}
		if(conn != null) {
			conn.close();
		}
	}
	public static void close(Connection conn,PreparedStatement ps) throws SQLException{
		if(ps != null) {
			ps.close();
		}
		if(conn != null) {
			conn.close();
		}
	}
}
